/*
 * @Description: 操作符
 * @Author: zzj
 * @Date: 2021-09-07 17:12:37
 * @LastEditors: zzj
 * @LastEditTime: 2021-09-07 17:21:17
 */

//算数运算符
var r1=100/3;
console.log(r1);//33.333333333333336
console.log(parseInt(r1));  //33

var a = 12;
//var result = 1+ --a;  //12  11
var result = 1+ a--;  //13  11
console.log(result);
console.log(a);

//笔试题：请预测结果
var a = 10;
var b = a++;  //b10  a11
var c = ++a;  //c12  a12
var d = --a;  //d11  a11
var e = a--;  //e11  a10
console.log(a,b,c,d,e);  //10 10 12 11

var a = "123";
console.log(+a); //Number()  123
console.log(-a); //-123
var b = 123;
console.log(+b);  //123
console.log(-b);  //-123
console.log(+'123');  //123
console.log(+'hello');  //NaN
console.log(+'123a');  //NaN
console.log(+'12.3');   //12.3
console.log(+'12.3.4'); //NaN
console.log(+'016');  //16  不识别8进制，识别成10进制
console.log(+'0xaa'); //170  //识别16进制
console.log(+' 123');  //123
console.log(+'12 3');  //NaN
console.log(+' 123 ');  //123
console.log(+'');   //0
console.log(+' ');  //0
//将boolean使用+转换成number
console.log(+true); //1 
console.log(+false);  //0
console.log(+undefined);  //NaN
console.log(+null);   //0

var obj = {
  name:"briup",
  valueOf:function(){
  return "1";
  }
}
console.log(obj+1);//"11"